//
//  GlobalMacro.swift
//
//
//  Created by 腾億 on 2017/11/30.
//  Copyright © 2017年 tml. All rights reserved.
//

import Foundation
import UIKit
import Kingfisher
import SnapKit
//屏幕的宽
public let kSCREEN_WIDTH = UIScreen.main.bounds.size.width

//屏幕的高
public let kSCREEN_HEIGHT = UIScreen.main.bounds.size.height

//低栏高度（适配iPhone X）
public let  kTabbarHeight = UIApplication.shared.statusBarFrame.size.height > 20 ? 83:49

//状态栏高度
public let kSCREEN_STAUSBAR = UIApplication.shared.statusBarFrame.size.height

//NAV高度
public let kSCREEN_NAVBAR: CGFloat = 44.0

//iPhone X 底部安全区域
public let kIPHONE_X_BOTTOMHEIGHT: CGFloat = 34.0

//iPhone 5/5S/5C (5系列)
public let isIPhone5 = kSCREEN_HEIGHT == 568 ? true : false

//iPhone 6/6s/7/8
public let isIPhone_678 = kSCREEN_HEIGHT == 667 ? true : false

//iPhone 6+/6s+/7+/8+
public let isIPhone_678p = kSCREEN_HEIGHT == 736 ? true : false

//iPhone X
public let isiPhone_X = kSCREEN_HEIGHT == 812 ? true : false

//RGBA函数
public func kRGBA (r:CGFloat, g:CGFloat, b:CGFloat, a:CGFloat) -> UIColor
{
    return UIColor(red: r/255.0, green: g/255.0, blue: b/255.0, alpha: a)
}

/// 版本号
public let versionCode = Bundle.main.infoDictionary?["CFBundleShortVersionString"] as! String

//Kingfisher
extension Kingfisher where Base: UIImageView {
    @discardableResult
    public func setImage(urlString: String?, placeholder: Placeholder? = UIImage(named: "normal_placeholder_h")) -> RetrieveImageTask {
        return setImage(with: URL(string: urlString ?? ""),
                        placeholder: placeholder,
                        options:[.transition(.fade(0.5))])
    }
}

//MARK: SnapKit
extension ConstraintView {
    
    var usnp: ConstraintBasicAttributesDSL {
        if #available(iOS 11.0, *) {
            return self.safeAreaLayoutGuide.snp
        } else {
            return self.snp
        }
    }
}


//服务器地址
public let BASE_URL = "http://app.u17.com/v3/appV3_3/ios/phone"

//请求key
public let requestKey = "fabe6953ce6a1b8738bd2cabebf893a472d2b6274ef7ef6f6a5dc7171e5cafb14933ae65c70bceb97e0e9d47af6324d50394ba70c1bb462e0ed18b88b26095a82be87bc9eddf8e548a2a3859274b25bd0ecfce13e81f8317cfafa822d8ee486fe2c43e7acd93e9f19fdae5c628266dc4762060f6026c5ca83e865844fc6beea59822ed4a70f5288c25edb1367700ebf5c78a27f5cce53036f1dac4a776588cd890cd54f9e5a7adcaeec340c7a69cd986:::open"

extension String {
    static let searchHistoryKey = "searchHistoryKey"
    static let sexTypeKey = "sexTypeKey"
}

extension NSNotification.Name {
    static let USexTypeDidChange = NSNotification.Name("USexTypeDidChange")
}



